/**
 * Map
 * 普通Map    var map={'first':'Dart','second':'Java'};
 * 常量Map    var map=const{'first':'Dart','second':'Java'};
 * 构造函数    var map=new Map();
 */

void main(){
  //key_value 可以是任何类型
  var map1={"first":"Dart",1:true};
  print(map1);
  print(map1["first"]);
  print(map1[1]);
  map1[1]=false;
  print(map1);

  var map3=new Map();


  //常量方式定义
  const map2={"first":"Dart",1:true};
  //map2[1]="Python";

  var map={"first":"Dart","second":"Java","third":"Python"};
  print(map.length);//长度

  print(map.isEmpty);//是否为空
  print(map.isNotEmpty);

  print(map.keys);
  print(map.values);

  print(map.containsKey('first'));
  print(map.containsValue('Java'));//是否包含value:Java

  map.remove('third');
  print(map);

  map.forEach(f);

  var list=["A","B","C","D"];
  print(list.asMap());//数组转Map,下标作为key存在
}

void f(key,value){
  print("Key=$key,value=$value");
}

